import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router'

const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      redirect: '/home'
    },
    {
      path: '/login',
      name: 'login',
      meta: {
        hidden: true
      },
      component: () => import('../views/login/index.vue'),
      redirect: '/login/login',
      children: [
        {
          path: 'login',
          name: 'login',
          component: () => import('../views/login/login.vue')
        },
        {
          path: 'register',
          name: 'register',
          component: () => import('../views/login/register.vue')
        },
        {
          path: 'password',
          name: 'password',
          component: () => import('../views/login/password.vue')
        },
      ]
    },
    {
      path: '/find',
      name: 'find',
      component: () => import('@/views/find/index.vue')
    },
    {
      path: '/home',
      name: 'home',
      component: () => import('@/views/home/index.vue'),
      redirect: '/home/home',
      children: [
        {
          path: 'home',
          name: 'home',
          component: () => import('@/views/home/home.vue'),
        },
        {
          path: 'detail2',
          name: 'detail2',
          meta: {
            hidden: true
          },
          component: () => import('../views/home/detail2.vue')
        },
        {
          path: 'like',
          name: 'like',
          meta: {
            hidden: true
          },
          component: () => import('@/views/home/like.vue'),
        },
        {
          path: 'history',
          name: 'history',
          meta: {
            hidden: true
          },
          component: () => import('@/views/home/history.vue'),
        },
      ]
    },
    {
      path: '/detail',
      name: 'detail',
      meta: {
        hidden: true
      },
      component: () => import('@/views/detail/index.vue'),
      redirect: '/detail/detail',
      children: [
        {
          path: 'detail',
          name: 'detail',
          component: () => import('@/views/detail/detail.vue'),
        },
        {
          path: 'confirm',
          name: 'confirm',
          component: () => import('@/views/detail/confirm.vue'),
        },
        {
          path: 'pay',
          name: 'pay',
          component: () => import('@/views/detail/pay.vue')
        },
        {
          path: 'paysuccess',
          name: 'paysuccess',
          component: () => import('@/views/detail/paysuccess.vue')
        },
        {
          path: 'cancel',
          name: 'cancel',
          component: () => import('@/views/detail/cancel.vue')
        },
        {
          path: 'orderdet',
          name: 'orderdet',
          component: () => import('@/views/detail/orderdet.vue')
        },
      ]
    },

    {
      path: '/user',
      name: 'user',
      component: () => import('@/views/user/index.vue'),
      redirect: '/user/user',
      children: [
        {
          path: 'user',
          name: 'user',
          component: () => import('@/views/user/user.vue'),
        },
        {
          path: 'newpsd',
          name: 'newpsd',
          meta: {
            hidden: true
          },
          component: () => import('@/views/user/newpsd.vue'),
        },
        {
          path: 'personal',
          name: 'personal',
          meta: {
            hidden: true
          },
          component: () => import('@/views/user/personal.vue'),
        },
        {
          path: 'feedback',
          name: 'feedback',
          meta: {
            hidden: true
          },
          component: () => import('@/views/user/feedback.vue'),
        },
        {
          path: 'master',
          name: 'master',
          meta: {
            hidden: true
          },
          component: () => import('@/views/user/master.vue'),
        },
        {
          path: 'homemsg',
          name: 'homemsg',
          meta: {
            hidden: true
          },
          component: () => import('@/views/user/homemsg.vue'),
        },
        {
          path: 'myorder',
          name: 'myorder',
          meta: {
            hidden: true
          },
          component: () => import('@/views/user/myorder.vue'),
        },
      ]
    },
    {
      path: '/chart',
      name: 'chart',
      component: () => import('@/views/chart/index.vue'),
      redirect: '/chart/chart',
      children: [
        {
          path: 'chart',
          name: 'chart',
          component: () => import('@/views/chart/chart.vue'),
        },
        {
          path: 'chartmsg',
          name: 'chartmsg',
          meta: {
            hidden: true
          },
          component: () => import('@/views/chart/chartmsg.vue')
        },
      ]
    },
  ]
})

export default router
